home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
ww_tv.exe
/
EDITS.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-08-21
|
8KB
|
297 lines
;/*------------------------------------------------------------*/
;/* filename - edits.asm */
;/* */
;/* function(s) */
;/* TEditor member functions */
;/*------------------------------------------------------------*/
;/*------------------------------------------------------------*/
;/* */
;/* Turbo Vision - Version 1.0 */
;/* */
;/* */
;/* Copyright (c) 1991 by Borland International */
;/* All Rights Reserved. */
;/* */
;/*------------------------------------------------------------*/
; Primatech Modifications History:
;** JAH 11-12-91 Check for soft-return, allow variable-size tabs
;** JLS 01-02-92 Added CLD at end of lineStart function as in BC++ 3.0
;** JLS 08-20-92 Allow user to set character displayed for hard return
IDEAL
MODEL LARGE, PROLOG
INCLUDE "TVWRITE.INC"
PUBLIC @TEditor@bufChar$xqus
PUBLIC @TEditor@bufPtr$xqus
PUBLIC @TEditor@formatLine$qnvusius
PUBLIC @TEditor@lineEnd$qus
PUBLIC @TEditor@lineStart$qus
PUBLIC @TEditor@nextChar$qus
PUBLIC @TEditor@prevChar$qus
CODESEG
;char TEditor::bufChar( ushort P ) const
PROC @TEditor@bufChar$xqus
ARG thisPtr:FAR PTR, P:WORD
USES DI
LES DI,[thisPtr]
MOV BX,[P]
CMP BX,[ES:DI+TEditorCurPtr]
JB @@1
ADD BX,[ES:DI+TEditorGapLen]
@@1: LES DI,[ES:DI+TEditorBuffer]
MOV AL,[ES:DI+BX]
RET
ENDP
;function TEditor::bufPtr( ushort P ) const
PROC @TEditor@bufPtr$xqus
ARG thisPtr:FAR PTR, P:WORD
USES DI
LES DI,[thisPtr]
MOV AX,[P]
CMP AX,[ES:DI+TEditorCurPtr]
JB @@1
ADD AX,[ES:DI+TEditorGapLen]
@@1: RET
ENDP
;void TEditor::formatLine( void *DrawBuf,
; ushort LinePtr,
; int Wide,
; ushort Colors
; )
PROC @TEditor@formatLine$qnvusius
ARG thisPtr:FAR PTR, DrawBuf:FAR PTR, LinePtr:WORD, Wide:WORD, Colors:WORD
USES DS,SI,DI
LOCAL TabSize:BYTE, Count:BYTE, RetChar:BYTE
LDS BX,[thisPtr]
LES DI,[DrawBuf]
MOV SI,[LinePtr]
MOV AL,[DS:BX+TEditorTabSize]
MOV [TabSize],AL
MOV AL,[DS:BX+TEditorRetChar]
MOV [RetChar],AL
XOR DX,DX
CLD
MOV AH,[BYTE PTR Colors]
MOV CX,[DS:BX+TEditorSelStart]
CALL @@10
MOV AH,[BYTE PTR Colors+1]
MOV CX,[DS:BX+TEditorCurPtr]
CALL @@10
ADD SI,[DS:BX+TEditorGapLen]
MOV CX,[DS:BX+TEditorSelEnd]
ADD CX,[DS:BX+TEditorGapLen]
CALL @@10
MOV AH,[BYTE PTR Colors]
MOV CX,[DS:BX+TEditorBufSize]
CALL @@10
JMP @@31
@@10: SUB CX,SI
JA @@11
RETN
@@11: LDS BX,[DS:BX+TEditorBuffer]
ADD SI,BX
MOV BX,[Wide]
@@12: LODSB
CMP AL,' '
JB @@20
@@13: STOSW
INC DX
@@14: CMP DX,BX
JAE @@30
LOOP @@12
LDS BX,[thisPtr]
SUB SI,[WORD PTR DS:BX+TEditorBuffer]
RETN
@@20: CMP AL,0Dh
JE @@29 ;@@30
CMP AL,09h
JNE @@13
PUSH AX
MOV AX,DX
DIV [TabSize] ;AH=remainder, AL=quotient
MOV AL,[TabSize]
SUB AL,AH ;compute spaces to next tab stop
MOV [Count],AL
POP AX
MOV AL,' ' ;put spaces in output buffer
@@21: STOSW
INC DX
CMP DX,BX
JAE @@30
DEC [Count]
JNZ @@21
JMP @@14
@@29: JCXZ @@30 ;
LODSB ;
CMP AL,0Ah ;have CR, check for hard-return (CR+LF)
JNE @@30 ;
MOV AL,[RetChar] ;
CMP AL,' ' ;check for space
JE @@30 ;don't store if it's a space
STOSW ;
INC DX ;
@@30: POP CX
@@31: MOV AL,' '
MOV CX,[Wide]
SUB CX,DX
JBE @@32
REP STOSW
@@32: RET
ENDP
;function TEditor.lineEnd(P: Word): Word; assembler;
PROC @TEditor@lineEnd$qus
ARG thisPtr:FAR PTR, P:WORD
USES DS,SI,DI
LDS SI,[thisPtr]
LES BX,[DS:SI+TEditorBuffer]
MOV DI,[P]
MOV AL,0Dh
CLD
MOV CX,[DS:SI+TEditorCurPtr]
SUB CX,DI
JBE @@1
ADD DI,BX
REPNE SCASB
JE @@2
MOV DI,[DS:SI+TEditorCurPtr]
@@1: MOV CX,[DS:SI+TEditorBufLen]
SUB CX,DI
JCXZ @@4
ADD BX,[DS:SI+TEditorGapLen]
ADD DI,BX
REPNE SCASB
JNE @@3
@@2: DEC DI
@@3: SUB DI,BX
@@4: MOV AX,DI
RET
ENDP
;function TEditor.lineStart(P: Word): Word; assembler;
PROC @TEditor@lineStart$qus
ARG thisPtr:FAR PTR, P:WORD
USES DS,SI,DI
LDS SI,[thisPtr]
LES BX,[DS:SI+TEditorBuffer]
MOV DI,[P]
MOV AL,0Dh
STD
MOV CX,DI
SUB CX,[DS:SI+TEditorCurPtr]
JBE @@1
ADD BX,[DS:SI+TEditorGapLen]
ADD DI,BX
DEC DI
REPNE SCASB
JE @@2
SUB BX,[DS:SI+TEditorGapLen]
MOV DI,[DS:SI+TEditorCurPtr]
@@1: MOV CX,DI
JCXZ @@4
ADD DI,BX
DEC DI
REPNE SCASB
JNE @@3
@@2: INC DI
INC DI
SUB DI,BX
CMP DI,[DS:SI+TEditorCurPtr]
JE @@4
CMP DI,[DS:SI+TEditorBufLen]
JE @@4
CMP [BYTE PTR ES:BX+DI],0Ah
JNE @@4
INC DI
JMP @@4
@@3: XOR DI,DI
@@4: MOV AX,DI
CLD
RET
ENDP
;function TEditor.nextChar(P: Word): Word; assembler;
PROC @TEditor@nextChar$qus
ARG thisPtr:FAR PTR, P:WORD
USES DS,SI,DI
LDS SI,[thisPtr]
MOV DI,[P]
CMP DI,[DS:SI+TEditorBufLen]
JE @@Done
INC DI
CMP DI,[DS:SI+TEditorBufLen]
JE @@Done
LES BX,[DS:SI+TEditorBuffer]
CMP DI,[DS:SI+TEditorCurPtr]
JB @@1
ADD BX,[DS:SI+TEditorGapLen]
@@1: MOV AX,[ES:BX+DI-1]
CMP AX,0A0Dh
JE @@Skip
CMP AH,0Dh ;check for soft-return
JNE @@Done
CMP [BYTE PTR ES:BX+DI+1],0Ah
JE @@Done
@@Skip: INC DI
@@Done: MOV AX,DI
RET
ENDP
;function TEditor.prevChar(P: Word): Word; assembler;
PROC @TEditor@prevChar$qus
ARG thisPtr:FAR PTR, P:WORD
USES DS,SI,DI
LDS SI,[thisPtr]
MOV DI,[P]
OR DI,DI
JE @@Done
DEC DI
JE @@Done
LES BX,[DS:SI+TEditorBuffer]
CMP DI,[DS:SI+TEditorCurPtr]
JB @@1
ADD BX,[DS:SI+TEditorGapLen]
@@1: MOV AX,[ES:BX+DI-1]
CMP AX,0A0Dh
JE @@Skip
CMP AH,0Dh ;check for soft-return
JNE @@Done
@@Skip: DEC DI
@@Done: MOV AX,DI
RET
ENDP
END